<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@2"></script>

<body>
    <div id="app">
        <h1>{{ getNow() }}</h1>
        <button v-on:click="reverseMessage">Reverse Message</button>
    </div>
    <script>
        new Vue({
            data: {
                message: 'Hello Vue.js!',
                date:new Date()
            },
            computed:{
                 now() {
                    let str = this.date.toLocaleTimeString()
                    setInterval(() => {
                        this.date = new Date();
                        str = this.date.toLocaleTimeString(); 
                    }, 1000);
                    return str;
                    
                 }
            },
            methods: {
                reverseMessage: function() {
                    this.message = this.message.split('').reverse().join('');
                },
                getNow() {
                    return new Date().toLocaleTimeString();
                }
            }
        }).$mount('#app')
    </script>
</body>
</html>